package com.frxuexi.park2210.adapter

import android.view.View
import android.widget.CheckBox
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.lib_base.entity.RepairBeanItem
import com.frxuexi.park2210.R

class RepairAdapter:BaseQuickAdapter<RepairBeanItem,BaseViewHolder>(R.layout.item_repair) {
    override fun convert(helper: BaseViewHolder, item: RepairBeanItem) {
        helper.getView<TextView>(R.id.repairData).setText(item.repairData)
        helper.getView<TextView>(R.id.repairDescribe).setText(item.repairDescribe)

        val btn_approve = helper.getView<TextView>(R.id.btn_approve)
        if(item.repairUserId!=0){//已经审批的
            val repairTime = helper.getView<TextView>(R.id.repairTime)
            repairTime.apply {
                visibility=View.VISIBLE
                repairTime.setText(item.repairTime?:"")
            }
            btn_approve.setText("已审核")
            btn_approve.setBackgroundResource(R.color.green)
        }

        val cb = helper.getView<CheckBox>(R.id.repair_cb)
        if(item.isShow){
            cb.visibility=View.VISIBLE
        }else{
            cb.visibility=View.GONE
        }
        cb.isChecked=item.isChecked

    }
}